﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyWeb.Business;
using MyWeb.Common;
namespace MyWeb.Module.Product
{
    public partial class GroupPro : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ShowProduct();
            }
        }
        protected string Formatmoney(string money)
        {
            string tien = "";
            try
            {
                tien = "" + Double.Parse(money).ToString("#,000") + " VNĐ";
            }
            catch
            {
                return tien = "";
            }
            return tien;
        }
        protected void ShowProduct()
        {
            List<Data.GroupProduct> list = GroupProductService.GroupProduct_GetByTop("","Active=1","");
            if (list.Count > 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    List<Data.Product> list1 = ProductService.Product_GetByTop("6", "GroupId in (select id from GroupProduct where left(Level,len('" + list[i].Level + "'))=" + list[i].Level + ")", "Date DESC");
                    if (list[i].Level.Length == 5)
                    {
                        ltrPro.Text += "<div class=\"headboxpro\">  <a href=\"\">"+list[i].Name+"</a></div> \n";
                        ltrPro.Text += "<div class=\"bodyboxpro\"> \n";
                        for (int j = 0; j < list1.Count; j++)
                        {                            
                            ltrPro.Text += "  <div class=\"prohome grid\"> \n";
                            ltrPro.Text += "<div class=\"div_img\"> \n";
                            ltrPro.Text += " <a class=\"tooltip\" href=\"/Pro/" + list1[j].GroupId + "/" + list1[j].Id + "/" + StringClass.NameToTag(list1[j].Name) + ".aspx\"><img src=\"" + list1[j].Image + "\" alt=\"" + list1[j].Name + "\"></a>";
                            ltrPro.Text += "</div>  \n";
                            ltrPro.Text += "<a class=\"productname tooltip\" href=\"/Product/" + list1[j].Id + "/" + StringClass.NameToTag(list1[j].Name) + ".aspx\">" + list1[j].Name + "</a> \n";
                            ltrPro.Text += "<div class=\"price\"><div class=\"gia\"><span>Giá bán:</span>"+list1[j].PriceNew+"</div></div> \n";
                            ltrPro.Text += "<div class=\"dathang\">";
                            ltrPro.Text += "<div class=\"order\"><a href=\"/Shop/"+list1[j].Id+".aspx\" title=\"\">Đặt mua</a></div> \n";
                            ltrPro.Text += "<div class=\"detail\"><a href=\"/Pro/" + list1[j].GroupId + "/" + list1[j].Id + "/" + StringClass.NameToTag(list1[j].Name) + ".aspx\" title=\"\">Chi tiết</a></div> \n";
                            ltrPro.Text += "</div>  \n";

                            ltrPro.Text += "<pre class=\"hidden\"><div class=\"boxpro\">  \n";                            
                            ltrPro.Text += "<div class=\"proname\">"+list1[j].Name+"</div> \n";
                            ltrPro.Text += "<div class=\"proimg1\"><a href=\"\"><img src=\""+list1[j].Image+"\" align=\"center\"></a></div> \n";
                            ltrPro.Text += "<div class=\"clear\"></div><div class=\"contentpro\"></div><div class=\"teaser\"></div> \n";
                            ltrPro.Text += "</div></pre> \n";
                            ltrPro.Text += "</div> \n";                            
                        }
                        ltrPro.Text += "<div class=\"clear\"></div> \n";
                        ltrPro.Text += "</div>";
                    }
                }
            }






        }
    }
}